/*!
 * \autor captainpeng
 * \date 2019-12-17
 * \version 1.0
 * \copyright
 */

#include<iostream>
#include<my.hpp>

int main(){
    using namespace std;
    using namespace my;
    my::ustring s("abc");
    s.each([](my::unicode_t u)->bool{ std::cout<<my::utf8::UnicodeToStr(u); return true;});
    std::cout<<std::endl;
    avl<int> tree;
    tree.insert(1);
    tree.insert(2);
    tree.insert(3);
    tree.print(std::cout);
    tree.each([](int a){ std::cout<<a<<std::endl; return true;});
    tree.erase(2);
    tree.print(std::cout);
    tree.free();
    tree.print(std::cout);

    buffer<int> a{1, 2, 3, 4, 5, 6};
    for(int i = 0; i < a.size(); ++i)
        std::cout<<a[i];
    std::cout<<std::endl<<"-------"<<std::endl;
    for(auto it = a.begin(); it != a.end(); ++it)
        std::cout<<(*it);
    std::cout<<std::endl<<"-------"<<std::endl;
    for(int i = -1; i >= a.ssize(); --i)
        std::cout<<a[i];
    std::cout<<std::endl<<"-------"<<std::endl;
    a.resize(10);
    for(int i = 0; i < a.size(); ++i)
        std::cout<<a[i];
    std::cout<<std::endl<<"-------"<<std::endl;
    for(int i = 0; i < a.size(); ++i)
        std::cout<<a[i];
    std::cout<<std::endl<<"---buffer end----"<<std::endl;

    seq<int> b{1, 2, 3, 4, 5, 6};
    for(int i = 0; i < b.size(); ++i)
        std::cout<<b[i]<<' ';
    std::cout<<std::endl<<"-------"<<std::endl;
    for(auto it = b.begin(); it != b.end(); ++it)
        std::cout<<(*it)<<' ';
    std::cout<<std::endl<<"-------"<<std::endl;
    for(int i = -1; i >= b.ssize(); --i)
        std::cout<<b[i]<<' ';
    std::cout<<std::endl<<"-------"<<std::endl;
    b.resize(3);
    for(int i = 0; i < b.size(); ++i)
        std::cout<<b[i]<<' ';
    std::cout<<std::endl<<"-------"<<std::endl;
    for(auto it = b.begin(); it != b.end(); ++it)
        std::cout<<(*it)<<' ';
    std::cout<<std::endl<<"-------"<<std::endl;

    b.chsize(1);
    b[-1] = 11;
    for(auto it = b.begin(); it != b.end(); ++it)
        std::cout<<(*it)<<' ';

    b.each([](int & a){ std::cout<<a<<std::endl; return true;});
    std::cout<<std::endl<<"---seq end----"<<std::endl;

    // seq<int> c(1024);
    // c+=10;
    // std::cout<<"c size = "<<c.size()<<std::endl;
    // for(int i = 0; i < c.size(); ++i)
    //     std::cout<<c[i];
    // c+=11;
    // std::cout<<"c size = "<<c.size()<<std::endl;
    // for(int i = 0; i < c.size(); ++i)
    //     std::cout<<c[i];

    return 0;
}
